//------------- login.js -------------//
$(document).ready(function() {


    $("#loginButton").click(function () {
        $.ajaxSetup({
            xhrFields: {withCredentials: true},
            crossDomain: true
        });
        var uname=$("input[name='name']").val();
        var pwd=$("input[name='password']").val();
        console.log("name:"+uname+" pwd:"+pwd);
		$.ajax({
            url: "http://localhost:8080/student/login",
            type: "get",
            data:"name="+uname+"&password="+pwd,
            dataType: "text",
            async:false,
			cache:false,
            success:function (msg) {
                if(msg==="s"){
                    window.location.href="../HTML/student/index.html"
                }else if(msg==="t"){
                    window.location.href="../HTML/teacher/index.html"
                }else{
                    layer.msg("登录失败！请重试！");
                }

            },
            error:function () {
                layer.msg("网络在开小差~稍后重试");
            }
        })
    });

});